#if !defined(MOUSECTRACERMANGERIMPL3_H_INCLUDED)
#define MOUSECTRACERMANGERIMPL3_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma warning(push)
#pragma warning(disable: 4786)	// identifier was truncated to "number'
								// characters in the debug information

#include "MouseTracerManager.h"

// forward reference;
template<class T>
class CMouseTracer;

/**
 *	CMouseTracerManagerImpl3 class
 *
 *	Type 3 : setup application hook to monitor mouse activities, especially button down message,
 *				to note the timiing at which CMouseTracer<CMouseTracerManager<CMouseTracerManagerImpl3> >-hook will be installed/removed dynamically on the active window
 *
 */
class CMouseTracerManagerImpl3
{
	friend class CMouseTracerManager<CMouseTracerManagerImpl3>;

public:
	static BOOL SetupMouseTracer(HINSTANCE hMod = NULL, DWORD dwThreadID = 0) { return CMouseTracerManagerImpl3::Instance().Setup(hMod, dwThreadID); }
	static void RemoveMouseTracer(DWORD dwThreadID = 0) { CMouseTracerManagerImpl3::Instance().Remove(dwThreadID); }

protected:
	static CMouseTracerManagerImpl3 &Instance() { static CMouseTracerManagerImpl3 instance; return instance; }

public:
	CMouseTracerManagerImpl3();
	virtual ~CMouseTracerManagerImpl3();

private:
	BOOL Setup(HINSTANCE hMod = NULL, DWORD dwThreadID = 0);
	void Remove(DWORD dwThreadID = 0);

private:
	static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
	
    static HHOOK m_hHook;
	static CMouseTracer<CMouseTracerManager<CMouseTracerManagerImpl3> > *m_pTracer;
	static BOOL m_bTracerDeleted;
};

#pragma warning(pop)

#endif // !defined(MOUSETRACERMANGERIMPL3_H_INCLUDED)
